package com.mmche.app.common;

import java.util.ArrayList;
import java.util.List;

import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import com.mmche.app.pojo.AccessToken;

public class WeixinUtil {
	public static AccessToken getAccessToken(){
		MappingJacksonHttpMessageConverter messageConverter = new MappingJacksonHttpMessageConverter();
	    List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
	    messageConverters.add(messageConverter);
	    RestTemplate restTemplate = new RestTemplate();
	    restTemplate.setMessageConverters(messageConverters);
		String url = Constant.ACCESS_TOKEN_URL;
		AccessToken accessToken = restTemplate.getForObject(url, AccessToken.class);
		return accessToken;
	}
}
